{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4108af17",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "旧的price_str id= 4376662832 \n",
      "新的price_str id= 4377904512 \n",
      "zhangk,boy,32\n",
      "zhangk,male,32\n",
      "   zhang\n",
      "000zhang\n",
      "zhang   |\n",
      "ppzhangppp\n",
      "1111\n",
      "15\n",
      "17\n",
      "f\n"
     ]
    }
   ],
   "source": [
    "price_str = '30.14, 29.58, 26.36, 32.56, 32.82'\n",
    "print('旧的price_str id= {} '.format(id(price_str)))\n",
    "price_str = price_str.replace(' ', '')\n",
    "print('新的price_str id= {} '.format(id(price_str)))\n",
    "price_str\n",
    "print('{},{},{}'.format('zhangk','boy',32))\n",
    "print('{name},{sex},{age}'.format(age=32,sex='male',name='zhangk'))\n",
    "print('{:>8}'.format('zhang'))\n",
    "print('{:0>8}'.format('zhang'))\n",
    "print('{: <8}|'.format('zhang'))\n",
    "print('{:p^10}'.format('zhang'))\n",
    "print('{:b}'.format(15))\n",
    "print('{:d}'.format(15))\n",
    "print('{:o}'.format(15))\n",
    "print('{:x}'.format(15))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "70137a34",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'26.36', '29.58', '30.14', '32.56', '32.82'}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "price_array=price_str.split(',')\n",
    "price_array.append('32.82')\n",
    "price_array\n",
    "set(price_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fa19a721",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['20210110', '20210111', '20210112', '20210113', '20210114']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "date_array=[]\n",
    "date_base=20210110\n",
    "price_cnt=len(price_array)-1\n",
    "while price_cnt>0:\n",
    "    date_array.append(str(date_base))\n",
    "    date_base +=1\n",
    "    price_cnt -=1\n",
    "    \n",
    "date_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b86e4d1b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['20210115', '20210116', '20210117', '20210118', '20210119', '20210120']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#列表推导式\n",
    "date_array= [str(date_base+ind) for ind,_ in enumerate(price_array)]\n",
    "date_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f65ceeb5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[('20210115', '30.14'),\n",
       " ('20210116', '29.58'),\n",
       " ('20210117', '26.36'),\n",
       " ('20210118', '32.56'),\n",
       " ('20210119', '32.82'),\n",
       " ('20210120', '32.82')]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_tuple_list=[(date,price) for date,price in zip(date_array, price_array)]\n",
    "stock_tuple_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "eec9d528",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[stock(date='20210115', price='30.14'),\n",
       " stock(date='20210116', price='29.58'),\n",
       " stock(date='20210117', price='26.36'),\n",
       " stock(date='20210118', price='32.56'),\n",
       " stock(date='20210119', price='32.82'),\n",
       " stock(date='20210120', price='32.82')]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#可命名元组\n",
    "from collections import namedtuple\n",
    "stock_namedtuple=namedtuple('stock', ('date', 'price'))\n",
    "stock_namedtuple\n",
    "stock_namedtuple_list=[stock_namedtuple(date,price) for date,price in zip(date_array, price_array)]\n",
    "stock_namedtuple_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "03a11eb4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20210117日价格：26.36\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'20210115'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_dict={date:price for date,price in  zip(date_array, price_array)}\n",
    "print('20210117日价格：{}'.format(stock_dict['20210117']))\n",
    "stock_dict\n",
    "stock_dict.keys(),stock_dict.values()\n",
    "min(stock_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "96fa6f1c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "odict_values(['30.14', '29.58', '26.36', '32.56', '32.82', '32.82'])"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from collections import OrderedDict\n",
    "stock_dict=OrderedDict((date,price) for date,price in  zip(date_array, price_array))\n",
    "stock_dict.keys()\n",
    "stock_dict.values()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "df24fb9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('26.36', '20210117')"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "min(zip(stock_dict.values(),stock_dict.keys()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "0ddc4dee",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[('26.36', '20210117'), ('29.58', '20210116'), ('30.14', '20210115'), ('32.56', '20210118'), ('32.82', '20210119'), ('32.82', '20210120')]\n",
      "('32.56', '20210118')\n"
     ]
    }
   ],
   "source": [
    "def find_second_max(dict_array):\n",
    "    stock_prices_sorted=sorted(zip(dict_array.values(),dict_array.keys()))\n",
    "    print(stock_prices_sorted)\n",
    "    return stock_prices_sorted[-3]\n",
    "if callable(find_second_max):\n",
    "    print(find_second_max(stock_dict))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "d060e4cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('32.82', '20210119')"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "find_second_max_lambda= lambda dict_array: sorted(zip(dict_array.values(),dict_array.keys()))[-2]\n",
    "find_second_max_lambda(stock_dict)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "e128a5b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(('26.36', '20210117'), ('32.82', '20210120'))"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def find_max_and_min(dict_array):\n",
    "    stock_prices_sorted=sorted(zip(dict_array.values(),dict_array.keys()))\n",
    "    return stock_prices_sorted[0],stock_prices_sorted[-1]\n",
    "find_max_and_min(stock_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e3021324",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[(30.14, 29.58),\n",
       " (29.58, 26.36),\n",
       " (26.36, 32.56),\n",
       " (32.56, 32.82),\n",
       " (32.82, 32.82)]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Require 5\n",
    "price_float_array=[float(price_str) for price_str in stock_dict.values()]\n",
    "pp_array=[(p1,p2) for p1,p2 in zip(price_float_array[:-1], price_float_array[1:])]\n",
    "pp_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "2784ea2b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, -0.019, -0.109, 0.235, 0.008, 0.0]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Python3 version: reduce has been removed from defined function list\n",
    "from functools import reduce\n",
    "change_array=list(map(\n",
    "    lambda pp: reduce(lambda a,b: round((b-a)/a,3), pp),\n",
    "    pp_array))\n",
    "change_array.insert(0,0)\n",
    "change_array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "c549589b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "OrderedDict([('20210115', stock(date='20210115', price='30.14', change=0)),\n",
       "             ('20210116',\n",
       "              stock(date='20210116', price='29.58', change=-0.019)),\n",
       "             ('20210117',\n",
       "              stock(date='20210117', price='26.36', change=-0.109)),\n",
       "             ('20210118', stock(date='20210118', price='32.56', change=0.235)),\n",
       "             ('20210119', stock(date='20210119', price='32.82', change=0.008)),\n",
       "             ('20210120', stock(date='20210120', price='32.82', change=0.0))])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_namedtuple=namedtuple('stock',('date','price','change'))\n",
    "stock_dict = OrderedDict((date, stock_namedtuple(date, price,change))\n",
    "                        for date, price,change in \n",
    "                        zip(date_array,price_array,change_array))\n",
    "stock_dict"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "760fe132",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[stock(date='20210118', price='32.56', change=0.235),\n",
       " stock(date='20210119', price='32.82', change=0.008)]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "up_days=filter(lambda day: day.change>0, stock_dict.values())\n",
    "list(up_days)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "30c6cc3e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, None, 2, None, 4, None, 6, None, 8, None]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "8"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#去掉奇数(奇淫巧技)\n",
    "print(list(map(lambda x:x if x-(x>>1)*2==0 else None, range(10))))\n",
    "#Why not?\n",
    "arr=list(map(lambda x:x if x%2==1 else None, range(10)))\n",
    "id(arr[0]),id(arr[1]),id(arr[2]),id(arr[-1])\n",
    "#变量指向同一个内存地址导致内存地址无变化，被最后一个值淹没\n",
    "x=lambda x:x if x-(x>>1)*2==0 else None\n",
    "list(map(lambda num: num if num%2==1 else None,range(11)))\n",
    "num=9\n",
    "(num>>1)*2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "5dce44de",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "所有上涨的交易日：[stock(date='20210118', price='32.56', change=0.235), stock(date='20210119', price='32.82', change=0.008)]\n",
      "所有下跌的交易日：[stock(date='20210116', price='29.58', change=-0.019), stock(date='20210117', price='26.36', change=-0.109)]\n",
      "所有上涨交易日的涨幅和：0.243\n",
      "所有下跌交易日的跌幅和：-0.128\n"
     ]
    }
   ],
   "source": [
    "def filter_stock(stock_array_dict, want_up=True, want_calc_sum=False):\n",
    "    if not isinstance(stock_array_dict, OrderedDict):\n",
    "        raise TypeError('stock_array_dict must be OrderedDict!')\n",
    "    filter_func = (lambda day: day.change>0) \\\n",
    "        if want_up else  (lambda day: day.change<0)\n",
    "    want_days = filter (filter_func, stock_array_dict.values())\n",
    "    if not want_calc_sum:\n",
    "        return want_days\n",
    "    change_sum = 0.0\n",
    "    for day in want_days:\n",
    "        change_sum += day.change\n",
    "    return change_sum\n",
    "print('所有上涨的交易日：{}'.format(list(filter_stock(stock_dict))))\n",
    "print('所有下跌的交易日：{}'.format(list(filter_stock(stock_dict, want_up=False))))\n",
    "print('所有上涨交易日的涨幅和：{}'.format(filter_stock(stock_dict,want_calc_sum=True)))\n",
    "print('所有下跌交易日的跌幅和：{}'.format(filter_stock(stock_dict,want_up=False,want_calc_sum=True)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "de099775",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "51\n",
      "sum\n"
     ]
    }
   ],
   "source": [
    "from functools import wraps  \n",
    "  \n",
    "def sum_add(*args1): #我们要给我们的装饰器decorator，带上参数  \n",
    "    def decorator(func):  \n",
    "        @wraps(func) #加上这句，原函数func被decorator作用后，函数性质不变  \n",
    "        def my_sum(*args2): #注意，参数要和原函数保持一致，真正实行扩展功能的是外层的装饰器  \n",
    "            my_s = 0  \n",
    "            for n in args1:  \n",
    "                my_s = my_s +n #这个是我们新加的求和结果  \n",
    "            return func(*args2) + my_s #这个，我们在原求和函数的结果上再加上s，并返回这个值  \n",
    "        return my_sum #返回my_sum函数，该函数扩展原函数的功能  \n",
    "    return decorator  #返回我们的装饰器  \n",
    " \n",
    "@sum_add(10,20) #启用装饰器 对sum函数进行功能扩展   \n",
    "def sum(*args):  \n",
    "    s = 0  \n",
    "    for n in args:  \n",
    "        s = s+n  \n",
    "    return s  \n",
    "print(sum(1,2,3,4,5,6))  \n",
    "print(sum.__name__) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "1b90d4df",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "所有上涨的交易日：[stock(date='20210118', price='32.56', change=0.235), stock(date='20210119', price='32.82', change=0.008)]\n",
      "所有下跌的交易日：[stock(date='20210116', price='29.58', change=-0.019), stock(date='20210117', price='26.36', change=-0.109)]\n",
      "所有上涨交易日的涨幅和：0.243\n",
      "所有下跌交易日的跌幅和：-0.128\n"
     ]
    }
   ],
   "source": [
    "from functools import partial\n",
    "#筛选上涨交易日\n",
    "filter_stock_up_days=partial(filter_stock, want_up=True, want_calc_sum=False)\n",
    "#筛选下跌交易日\n",
    "filter_stock_down_days=partial(filter_stock, want_up=False, want_calc_sum=False)\n",
    "#筛选计算上涨交易日涨幅和\n",
    "filter_stock_up_sums=partial(filter_stock, want_up=True, want_calc_sum=True)\n",
    "#筛选计算下跌交易日涨幅和\n",
    "filter_stock_down_sums=partial(filter_stock, want_up=False, want_calc_sum=True)\n",
    "print('所有上涨的交易日：{}'.format(list(filter_stock_up_days(stock_dict))))\n",
    "print('所有下跌的交易日：{}'.format(list(filter_stock_down_days(stock_dict))))\n",
    "print('所有上涨交易日的涨幅和：{}'.format(filter_stock_up_sums(stock_dict)))\n",
    "print('所有下跌交易日的跌幅和：{}'.format(filter_stock_down_sums(stock_dict)))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "2ba87ab6",
   "metadata": {},
   "outputs": [],
   "source": [
    "class StockTradeDays(object):\n",
    "    def __init__(self, price_array, start_date, date_array=None):\n",
    "        # 私有价格序列\n",
    "        self.__price_array = price_array\n",
    "        # 私有日期序列\n",
    "        self.__date_array = self._init_days(start_date, date_array)\n",
    "        # 私有涨跌幅序列\n",
    "        self.__change_array = self.__init_change()\n",
    "        # 进行OrderedDict的组装\n",
    "        self.stock_dict = self._init_stock_dict()\n",
    "\n",
    "    def __init_change(self):\n",
    "        \"\"\"\n",
    "        从price_array生成change_array\n",
    "        :return:\n",
    "        \"\"\"\n",
    "        price_float_array = [float(price_str) for price_str in\n",
    "                             self.__price_array]\n",
    "        # 通过将时间平移形成两个错开的收盘价序列，通过zip打包成为一个新的序列\n",
    "        # 每个元素为相邻的两个收盘价格\n",
    "        pp_array = [(price1, price2) for price1, price2 in\n",
    "                    zip(price_float_array[:-1], price_float_array[1:])]\n",
    "        # list for python3\n",
    "        change_array = list(map(lambda pp: reduce(lambda a, b: round((b - a) / a, 3), pp), pp_array))\n",
    "        # list insert插入数据，将第一天的涨跌幅设置为0\n",
    "        change_array.insert(0, 0)\n",
    "        return change_array\n",
    "\n",
    "    def _init_days(self, start_date, date_array):\n",
    "        \"\"\"\n",
    "        protect方法，\n",
    "        :param start_date: 初始日期\n",
    "        :param date_array: 给定日期序列\n",
    "        :return:\n",
    "        \"\"\"\n",
    "        if date_array is None:\n",
    "            # 由start_date和self.__price_array来确定日期序列\n",
    "            date_array = [str(start_date + ind) for ind, _ in\n",
    "                          enumerate(self.__price_array)]\n",
    "        else:\n",
    "            # 稍后的内容会使用外部直接设置的方式\n",
    "            # 如果外面设置了date_array，就直接转换str类型组成新date_array\n",
    "            date_array = [str(date) for date in date_array]\n",
    "        return date_array\n",
    "\n",
    "    def _init_stock_dict(self):\n",
    "        \"\"\"\n",
    "        使用namedtuple，OrderedDict将结果合并\n",
    "        :return:\n",
    "        \"\"\"\n",
    "        stock_namedtuple = namedtuple('stock',\n",
    "                                      ('date', 'price', 'change'))\n",
    "\n",
    "        # 使用以被赋值的__date_array等进行OrderedDict的组装\n",
    "        stock_dict = OrderedDict(\n",
    "            (date, stock_namedtuple(date, price, change))\n",
    "            for date, price, change in\n",
    "            zip(self.__date_array, self.__price_array,\n",
    "                self.__change_array))\n",
    "        return stock_dict\n",
    "\n",
    "    def filter_stock(self, want_up=True, want_calc_sum=False):\n",
    "        \"\"\"\n",
    "        筛选结果子集\n",
    "        :param want_up: 是否筛选上涨\n",
    "        :param want_calc_sum: 是否计算涨跌和\n",
    "        :return:\n",
    "        \"\"\"\n",
    "        # Python中的三目表达式的写法\n",
    "        filter_func = (lambda p_day: p_day.change > 0) if want_up else (\n",
    "            lambda p_day: p_day.change < 0)\n",
    "        # 使用filter_func做筛选函数\n",
    "        want_days = list(filter(filter_func, self.stock_dict.values()))\n",
    "\n",
    "        if not want_calc_sum:\n",
    "            return want_days\n",
    "\n",
    "        # 需要计算涨跌幅和\n",
    "        change_sum = 0.0\n",
    "        for day in want_days:\n",
    "            change_sum += day.change\n",
    "        return change_sum\n",
    "\n",
    "    \"\"\"\n",
    "        下面的__str__，__iter__， __getitem__， __len__稍后会详细讲解作\n",
    "    \"\"\"\n",
    "\n",
    "    def __str__(self):\n",
    "        return str(self.stock_dict)\n",
    "\n",
    "    __repr__ = __str__\n",
    "\n",
    "    def __iter__(self):\n",
    "        \"\"\"\n",
    "        通过代理stock_dict的跌倒，yield元素\n",
    "        :return:\n",
    "        \"\"\"\n",
    "        for key in self.stock_dict:\n",
    "            yield self.stock_dict[key]\n",
    "\n",
    "    def __getitem__(self, ind):\n",
    "        date_key = self.__date_array[ind]\n",
    "        return self.stock_dict[date_key]\n",
    "\n",
    "    def __len__(self):\n",
    "        return len(self.stock_dict)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "6aa5bf1c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "trade_days: OrderedDict([('20211018', stock(date='20211018', price='30.14', change=0)), ('20211019', stock(date='20211019', price='29.58', change=-0.019)), ('20211020', stock(date='20211020', price='26.36', change=-0.109)), ('20211021', stock(date='20211021', price='32.56', change=0.235)), ('20211022', stock(date='20211022', price='32.82', change=0.008))])\n",
      "trade_days对象长度为: 5\n"
     ]
    }
   ],
   "source": [
    "price_array = '30.14,29.58,26.36,32.56,32.82'.split(',')\n",
    "date_base = 20211018\n",
    "# 从StockTradeDays类初始化一个实例对象trade_days，内部会调用__init__\n",
    "trade_days = StockTradeDays(price_array, date_base)\n",
    "# 打印对象信息\n",
    "print('trade_days:', trade_days)\n",
    "print('trade_days对象长度为: {}'.format(len(trade_days)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "61eabb50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "stock(date='20211018', price='30.14', change=0)\n",
      "stock(date='20211019', price='29.58', change=-0.019)\n",
      "stock(date='20211020', price='26.36', change=-0.109)\n",
      "stock(date='20211021', price='32.56', change=0.235)\n",
      "stock(date='20211022', price='32.82', change=0.008)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[stock(date='20211021', price='32.56', change=0.235),\n",
       " stock(date='20211022', price='32.82', change=0.008)]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from collections import Iterable\n",
    "    # 如果是trade_days是可迭代对象，依次打印出\n",
    "if isinstance(trade_days, Iterable):\n",
    "    for day in trade_days:\n",
    "        print(day)\n",
    "#print(trade_days.filter_stock())\n",
    "trade_days.filter_stock()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "761dc276",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
